package com.only4play.practice.pay.reconcile.core.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.only4play.codegen.processor.api.*;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.creator.IgnoreCreator;
import com.only4play.codegen.processor.dto.GenDto;
import com.only4play.codegen.processor.entitymapper.GenObjectMapper;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.updater.IgnoreUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.codegen.support.annotation.FieldDesc;
import com.only4play.codegen.support.constants.ValidStatus;
import com.only4play.codegen.support.model.BaseEntity;
import com.only4play.practice.common.enums.IncomeType;
import com.only4play.practice.common.enums.OrderState;
import com.only4play.practice.common.enums.pay.OutPayChannelType;
import com.only4play.practice.common.enums.pay.TradeTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@GenCreator(pkgName = "com.only4play.practice.pay.reconcile.model.creator")
@GenUpdater(pkgName = "com.only4play.practice.pay.reconcile.model.updater")
// findById方法
@GenVo(pkgName = "com.only4play.practice.pay.reconcile.model.vo")
// findByPage方法
@GenQuery(pkgName = "com.only4play.practice.pay.reconcile.model.query")
@GenCreateRequest(pkgName = "com.only4play.practice.pay.reconcile.model.request")
@GenUpdateRequest(pkgName = "com.only4play.practice.pay.reconcile.model.request")
@GenQueryRequest(pkgName = "com.only4play.practice.pay.reconcile.model.request")
@GenResponse(pkgName = "com.only4play.practice.pay.reconcile.model.response")
@GenDto(pkgName = "com.only4play.practice.pay.reconcile.model.dto")

@GenFeign(pkgName = "com.only4play.practice.pay.reconcile.model.feign")

// 生成serviceImpl
@GenObjectMapper(pkgName = "com.only4play.practice.pay.reconcile.entitymapper")
// 生成serviceImpl
@GenMapper(pkgName = "com.only4play.practice.pay.reconcile.core.mapper")
@GenService(pkgName = "com.only4play.practice.pay.reconcile.core.service")
@GenServiceImpl(pkgName = "com.only4play.practice.pay.reconcile.core.service.impl")

@GenController(pkgName = "com.only4play.practice.pay.reconcile.core.controller")
/**
 * @author mdy
 * * @date 2024/9/27
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("pay_platform_order")
public class PlatformOrder extends BaseEntity {

    @FieldDesc(name = "平台交易订单号")
    private Long tradeOrderNo;

    @FieldDesc(name = "支付渠道订单号")
    private Long outTradeOrderNo;

    @FieldDesc(name = "交易订单状态")
    private OrderState tradeOrderStatus;

    @FieldDesc(name = "总金额")
    private Long totalAmount;

    @FieldDesc(name = "优惠金额")
    private Long discountAmount;

    @FieldDesc(name = "实付金额 || 交易金额")
    private Long payAmount;

    @FieldDesc(name = "退款金额")
    private Long successRefundAmount;

    @FieldDesc(name = "手续费")
    private Long fee;

    @FieldDesc(name = "订单支付渠道")
    private OutPayChannelType channelType;

    @FieldDesc(name = "订单信息")
    private String orderInfo;

    @FieldDesc(name = "收入类型")
    private IncomeType incomeType;

    @FieldDesc(name = "交易类型")
    private TradeTypeEnum tradeType;

    /** 创建订单时间 **/
    private Date createTradeOrderTime;

    @FieldDesc(name = "支付时间")
    private Date tradeOrderPayTime;

    @FieldDesc(name = "付款人信息")
    private String payerInfo;

    @FieldDesc(name = "支付扩展信息")
    private String payExt;

    /** 状态 */
    @IgnoreUpdater
    @IgnoreCreator
    private ValidStatus validStatus;

    public void init() {
        setValidStatus(ValidStatus.VALID);
    }

    public void valid(){
        setValidStatus(ValidStatus.VALID);
    }

    public void invalid(){
        setValidStatus(ValidStatus.INVALID);
    }
}
